package Homework;

public class Homework02 {

    public static void main(String[] args) {

        String s1 = "asdafghjka";
        String s2 = "aaasdfg";
        String s3 = "";
        boolean flag = false;
        for (int i = 0;i < s2.length();i ++) {
            for (int j = 0,k = s2.length() - i;k != s2.length() + 1;j++,k++) {
                String com = s2.substring(j,k);
                if (s1.contains(com)) {
                    s3 = com;
                    flag = true;
                    break;
                }
            }
            if(flag){
                break;
            }
        }
        System.out.println("最大相同子串为： " + s3);
    }
}
